package bd403.utils;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import bd403.namespace.R;

/* Adapter for the Help class.
 * Main author: Joe
 */

public class HelpAdapter extends ArrayAdapter<String> {
	private final Activity context;
	private ArrayList<String> topic;
	
	public HelpAdapter (Activity context, int textViewResourceId, ArrayList<String> items) {
		super(context, R.layout.helpitem, items);
		this.context = context;
		this.topic = items;
	}
	
	/* Returns a view for the Help page.
	 */
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
			LayoutInflater inflater = context.getLayoutInflater();
			v = inflater.inflate(R.layout.helpitem, null);
		}
		
		String s = topic.get(position);
		if (s != null) {
			TextView ht = (TextView) v.findViewById(R.id.helptitle);
			if (ht != null) {
				ht.setText(s);
			}
		}
		return v;
	}
}
